<%@ page import="com.mysql.cj.jdbc.ConnectionGroupManager" %>
<%@ page import="java.sql.Connection" %>
<%@ page import="java.sql.DriverManager" %>
<%@ page import="java.sql.SQLException" %>
<%@ page import="entity.other.File" %>
<%@ page import="org.apache.commons.dbutils.handlers.BeanListHandler" %>
<%@ page import="java.util.List" %>
<%@ page import="org.apache.commons.dbutils.*" %><%--
  Created by IntelliJ IDEA.
  User: 李学健
  Date: 2024/4/1
  Time: 0:01
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
<%--资源管理;对举报进行处理;还没写--%>
<%--关于文件删除--%>
<%--https://blog.csdn.net/qq_33887333/article/details/73545324--%>
<h1 style="color: #3880c2">
    <a href="index.jsp" style="color: crimson">返回登录</a>
</h1>
<center>
    <h1>举报管理</h1>
    <%
        List<File> fileList;
        try {
            //queryRunner查询公开文件
            Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/mybatis?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&serverTimezone=Asia/Shanghai", "root", "123456");
            QueryRunner queryRunner = new QueryRunner();
            //解决字段映射问题
            BasicRowProcessor basicRowProcessor = new BasicRowProcessor(new GenerousBeanProcessor());
            fileList = queryRunner.query(connection, "select f.*,u.username from file f inner join user u on u.id=f.user_id where is_delete = 1"
                    , new BeanListHandler<File>(File.class, basicRowProcessor));                    //basicRowProcessor放在new BeanListHandler里面
            connection.close();
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
        for (File file : fileList) {
            out.write("<h2>举报受理文件(点击下载文件):</h2>");
            out.write("<br><br><br>");
            out.write("<a href=\"DownloadServlet?filePath=" + file.getFilePath() + "\">" + file.getFileName()
                    + "</a>" + " <a style=\"color: red;\" href=\"DeleteReportedSerevlet?fileId=" + file.getId() + "&filePath=" + file.getFilePath() + "\">删除文件</a>" +
                    "<br>上传用户 : " + file.getUserName() + "上传时间: " + file.getUpTime() + "下载量:" + file.getDownload() + "<br>");
        }
    %>
</center>

</body>
</html>
